<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .bw3 {
            width: 100px;
            height: 200px;
            background-color: violet;
        }

        .bw33 {
            width: 100px;
            height: 200px;
            background-color: rgb(130, 238, 171);
        }
    </style>
</head>

<body>
    <!-- <div id="bw1" aaa="bw2" class="bw3" index="bw4" ></div> -->
    <!-- 
        自定义属性的时候：data-*
        *：代表的是任意字符串

     -->
    <div id="user" data-id="1234567890" data-user="johndoe" data-date-of-birth="20221010" data-date-of-birth1>
        John Doe
    </div>
    <script>
        // const divObj = document.querySelector("div");

        // 方式一
        // divObj.className = 'bw33';

        // 方式二
        // divObj.setAttribute("class","bw33");

        const divObj = document.querySelector("div");
        console.log(divObj.dataset);
        console.log(divObj.dataset.id);
        //写法一
        console.log(divObj.dataset.user);
        //写法二
        console.log(divObj.dataset['user']);
        //这个是规范
        console.log(divObj.dataset.dateOfBirth);
        console.log(divObj.dataset.dateOfBirth1);
        console.log(divObj.dataset.dateOfBirth2);



    </script>

</body>

</html>